﻿using Nest;
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;

namespace ES.Client.Filter
{
    public interface IFilterBuilder
    {
        IEnumerable<QueryContainer> EQ<TValue>(string field, TValue value);

        IEnumerable<QueryContainer> NE<TValue>(string field, TValue value);

        IEnumerable<QueryContainer> GT<TValue>(string field, TValue value);

        IEnumerable<QueryContainer> GTE<TValue>(string field, TValue value);

        IEnumerable<QueryContainer> LT<TValue>(string field, TValue value);

        IEnumerable<QueryContainer> LTE<TValue>(string field, TValue value);

        /// <summary>
        /// 判断文档是否包含某个字段，字段值既不等于null也不等于空字符串
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        IEnumerable<QueryContainer> Exists(string field);

        /// <summary>
        /// 通过给定字段获取文档，字段值既不等于null也不等于空字符串
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        IEnumerable<QueryContainer> IsNotNullAndEmpty(string field);

        /// <summary>
        /// 判断文档是否不包含某个文档，字段值等于null或者等于空字符串
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        IEnumerable<QueryContainer> Missing(string field);

        /// <summary>
        /// 通过给定字段获取文档，字段值等于null或者等于空字符串
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        IEnumerable<QueryContainer> IsNullOrEmpty(string field);

        /// <summary>
        /// 以特定前缀搜索
        /// </summary>
        /// <param name="field"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        IEnumerable<QueryContainer> Prefix(string field, string query);

        /// <summary>
        /// 指定字段模糊搜索
        /// </summary>
        /// <param name="field"></param>
        /// <param name="keyword"></param>
        /// <returns></returns>
        IEnumerable<QueryContainer> Like(string field, string keyword);

        /// <summary>
        /// 正则表达式搜索
        /// </summary>
        /// <param name="field"></param>
        /// <param name="regex"></param>
        /// <returns></returns>
        IEnumerable<QueryContainer> Regex(string field, string regex);

        /// <summary>
        /// IN查询
        /// </summary>
        /// <typeparam name="TValue"></typeparam>
        /// <param name="field"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        IEnumerable<QueryContainer> IN<TValue>(string field, IEnumerable<TValue> values);
    }
}
